//  this library.
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hktk_app/util/view_util.dart';

/// 随机组卷背景
class TestBackgroundWidget extends StatelessWidget {
  /// 内容显示
  final Widget widget;

  const TestBackgroundWidget({
    super.key,
    required this.widget,
  });

  @override
  Widget build(BuildContext context) {

    return Stack(
      children: [
        Positioned(
          // top: 50,
          child: _backgroundItem(),
        ),
        Positioned(
          top: 0,
          left: 0,
          right: 0,
          child: _titleItem(),
        ),
      ],
    );
  }

  /// 标题
  _titleItem() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        SvgPicture.asset(
          "images/subject/test_background_title.svg",
          width: 1.sw-(36),
          // height: 50,
        ),
      ],
    );
  }

  /// 背景内容显示
  _backgroundItem() {
    return Container(
      margin: EdgeInsets.only(top: 55),
      padding: EdgeInsets.symmetric(
        horizontal: 20,
        vertical: 16,
      ),
      decoration: BoxDecoration(
        color: colorOrange14,
        borderRadius: BorderRadius.circular(30),
      ),
      child: Container(
        padding: EdgeInsets.symmetric(
          horizontal: 10,
          vertical: 9,
        ),
        decoration: BoxDecoration(
          color: colorOrange15,
          borderRadius: BorderRadius.circular(10),
        ),
        child: _content(),
      ),
    );
  }

  /// 内容组件显示
  _content() {
    return Container(
      width: 624,
      constraints: BoxConstraints(
        // 最小高度
        minHeight: 892,
      ),
      padding: EdgeInsets.all(16),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(4),
        gradient: const LinearGradient(
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
          colors: [colorWhite1, colorWhite3],
        ),
      ),
      child: _contentItem(),
    );
  }

  /// 具体内容显示
  _contentItem() {
    return Column(
      children: [
        hiSpace(height: 64),
        _horizontalItem(),
        hiSpace(height: 30),
        _horizontalItem(),
        hiSpace(height: 42),
        widget,
      ],
    );
  }

  /// 横线组件
  _horizontalItem() {
    return Container(
      width: 520,
      height: 8,
      decoration: const BoxDecoration(color: colorOrange16),
    );
  }
}
